Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MultinomialSampler hyperparameter bug #1150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aidansan
Copy link

Currently seems like the MultinomialSampler does not utilize all logit_processors, only the last one in self.logit_processors. Thus, some of the hyperparameters (i.e. top_k) are not utilized. This fixes this issue with a small variable change.

Copy link
Contributor

@lapp0 lapp0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. However I'm not sure we will be using Sampler.__call__ in v0.1.0.

Did you see this behavior cause an issue somewhere?

@aidansan
Copy link
Author

I initialized a sampler and passed it into a regex generator.

sampler = outlines.samplers.MultinomialSampler(temperature=1.5, top_k=100, samples=5)
generator = outlines.generate.regex(
    model,
    r"I really love (\S*) cake with ice cream.",
    sampler=sampler
)
structured = generator(prompt, max_tokens=30)

First generate.api.SequenceGenerator.__call__ is called

which calls generate.generator.sequence_generator

which calls sampler.__call__

@lapp0
Copy link
Contributor

lapp0 commented Sep 15, 2024

I assume this was with ExLlamaV2, or am I wrong? Good find.

Uses all logit_processors instead of just the last logit_processor
@aidansan
Copy link
Author

I'm not sure about ExLlamaV2, but maybe? This was my model initialization code model = outlines.models.transformers("meta-llama/Meta-Llama-3-8B")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants